package cn.biplam.common.client;

import java.rmi.RemoteException;

import cn.biplam.common.interfaces.AjxExchangeServer;
import cn.biplam.common.tools.RMITOOLS;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.KvMap;
import cn.biplam.common.wrapper.UserInfo;

/**
 * 页面请求交换类
 * @author WangSong 2009-9-22下午07:23:57
 * @version 1.0
 */
public abstract class AjxExchange {
	
	/**
	 * 取请求页面
	 * @param action 行为id
	 * @param params 参数容器
	 * @param homeUrl 系统路径
	 * @param user 用户信息
	 * @return 	String 请求的页面内容文本
	 * @throws RemoteException
	 * @throws ErrorMessage
	 */
	public static String get(String action, 
			  		         KvMap<String, String> params,
			  		         String homeUrl, 
			  		         UserInfo user) throws ErrorMessage {
		String content = null;
		
		try {
			AjxExchangeServer mAjxExchangeServer = (AjxExchangeServer)RMITOOLS.getInstance("AjxExchangeServer");
			content = mAjxExchangeServer.get(action,params,homeUrl,user);
		} catch (ErrorMessage e) {
			throw e;
		} catch (Exception e) {
			throw new ErrorMessage(e,"AjxExchange.get failed("+action+") ");
		}
		return content;
	}
	
}
